
Imports System.Collections
Imports System.Data.SqlClient
Imports _2bMatesSite.Common

Namespace _2bMatesSite.BO
	''' <summary>
	''' Summary description for LabelTypes.
	''' </summary>
	Public Class LabelTypes
		Protected list As ArrayList
		Protected hash As Hashtable

		Public Sub New()
			LoadLabelTypes()
		End Sub

		Public ReadOnly Property List() As ArrayList
			Get
				Return list
			End Get
		End Property

		Public Function GetLabelTypeByID(ByVal LabelTypeID As Integer) As LabelType
			Return DirectCast(hash(LabelTypeID), LabelType)
		End Function

		Protected Sub LoadLabelTypes()
			list = New ArrayList()
			hash = New Hashtable()

			Dim conn As SqlConnection = DBManager.GetUnmanagedConnection()

			Try
				Dim cmd As New SqlCommand("SELECT * FROM LabelTypes ORDER BY Name ASC")
				cmd.Connection = conn

				Dim dr As SqlDataReader = cmd.ExecuteReader()

				Dim ordID As Integer = dr.GetOrdinal("ID")
				Dim ordName As Integer = dr.GetOrdinal("Name")

				While dr.Read()
					Dim lt As New LabelType(dr.GetInt32(ordID), dr.GetString(ordName))

					list.Add(lt)
					hash(lt.ID) = lt
				End While

				dr.Close()
			Finally
				conn.Close()
			End Try
		End Sub

		Public Class LabelType
			Public ID As Integer
			Public Name As String

			Public Sub New(ByVal ID As Integer, ByVal Name As String)
				Me.ID = ID
				Me.Name = Name
			End Sub
		End Class
	End Class
End Namespace






